package com.ibm.spatiotemp.server.datamodel.gpsdata.mysql;

import java.sql.ResultSet;

import org.apache.log4j.Logger;

import com.ibm.spatiotemp.server.datamodel.gpsdata.TSPoint;
import com.ibm.spatiotemp.server.datamodel.gpsdata.TSPointResultSet;

public class MysqlTSPointResultSet extends TSPointResultSet {
	public static Logger logger = Logger.getLogger(MysqlTSPointResultSet.class);
	private ResultSet resultSet = null;
	
	MysqlTSPointResultSet(){}
	public MysqlTSPointResultSet(ResultSet sqlresset){
		resultSet = sqlresset;
	}
	
	@Override
	public void close() throws Exception {
		resultSet.close();
	}

	@Override
	public TSPoint getNext() throws Exception{
		if (resultSet != null && resultSet.next()) {
			String movid = resultSet.getString(1);
			double x = resultSet.getDouble(2);
			double y = resultSet.getDouble(3);
			long timestamp = resultSet.getLong(4);
			return new TSPoint(movid,x,y,timestamp);
			}
		else {
				logger.debug("result set is empty now");
			}

		return null;
	}


}
